home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / windows / tpwin31.zip / VER.PAS < prev    next >
Pascal/Delphi Source File  |  1992-04-06  |  7KB  |  197 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Turbo Pascal for Windows Run-time Library       }
  5. {       Windows 3.1 API Interface Unit                  }
  6. {                                                       }
  7. {       Copyright (c) 1991 Borland International        }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit Ver;
  12.  
  13. interface
  14.  
  15. uses WinTypes;
  16.  
  17. const
  18.   { Symbols }
  19.   vs_File_Info = PChar(16);        { Version stamp res type }
  20.   vs_Version_Info = PChar(1);          { Version stamp res ID }
  21.   vs_User_Defined = PChar(100);        { User-defined res IDs }
  22.  
  23.   { vs_Version.dwFileFlags }
  24.   vs_FFI_Signature = $FEEF04BD;
  25.   vs_FFI_StrucVersion = $00010000;
  26.   vs_FFI_FileFlagsMask = $0000003F;
  27.  
  28.   { vs_Version.dwFileFlags }
  29.   vs_FF_Debug = $00000001;
  30.   vs_FF_Prerelease = $00000002;
  31.   vs_FF_Patched = $00000004;
  32.   vs_FF_PrivateBuild = $00000008;
  33.   vs_FF_InfoInferred = $00000010;
  34.   vs_FF_SpecialBuild = $00000020;
  35.  
  36.   { vs_Version.dwFileOS }
  37.   vos_Unknown = $00000000;
  38.   vos_DOS = $00010000;
  39.   vos_OS216 = $00020000;
  40.   vos_OS232 = $00030000;
  41.   vos_NT = $00040000;
  42.  
  43.   vos__Base = $00000000;
  44.   vos__Windows16 = $00000001;
  45.   vos__PM16 = $00000002;
  46.   vos__PM32 = $00000003;
  47.   vos__Windows32 = $00000004;
  48.  
  49.   vos_DOS_Windows16 = $00010001;
  50.   vos_DOS_Windows32 = $00010004;
  51.   vos_OS216_PM16 = $00020002;
  52.   vos_OS232_PM32 = $00030003;
  53.   vos_NT_Windows32 = $00040004;
  54.  
  55.   { vs_Version.dwFileType }
  56.   vft_Unknown = $00000000;
  57.   vft_APP = $00000001;
  58.   vft_DLL = $00000002;
  59.   vft_DRV = $00000003;
  60.   vft_Font = $00000004;
  61.   vft_VXD = $00000005;
  62.   vft_Static_Lib = $00000007;
  63.  
  64.   { vs_Version.dwFileSubtype for vft_Windows_DRV }
  65.   vft2_Unknown = $00000000;
  66.   vft2_DRV_Printer = $00000001;
  67.   vft2_DRV_Keyboard = $00000002;
  68.   vft2_DRV_Language = $00000003;
  69.   vft2_DRV_Display = $00000004;
  70.   vft2_DRV_Mouse = $00000005;
  71.   vft2_DRV_Network = $00000006;
  72.   vft2_DRV_System = $00000007;
  73.   vft2_DRV_Installable = $00000008;
  74.   vft2_DRV_Sound = $00000009;
  75.   vft2_DRV_Comm = $00000000A;
  76.  
  77.   { vs_Version.dwFileSubtype for vft_Windows_Font }
  78.   vft2_Font_Raster = $00000001;
  79.   vft2_Font_Vector = $00000002;
  80.   vft2_Font_TrueType = $00000003;
  81.  
  82.   { VerFindFile() flags }
  83.   vfff_IsSharedFile = $0001;
  84.  
  85.   vff_CurNEDest = $0001;
  86.   vff_FileInUse = $0002;
  87.   vff_BuffTooSmall = $0004;
  88.  
  89.   { VerInstallFile() flags }
  90.   viff_ForceInstall = $0001;
  91.   viff_DontDeleteOld = $0002;
  92.  
  93.   vif_TempFile = $00000001;
  94.   vif_Mismatch = $00000002;
  95.   vif_SrcOld = $00000004;
  96.  
  97.   vif_DiffLang = $00000008;
  98.   vif_DiffCodePg = $00000010;
  99.   vif_DiffType = $00000020;
  100.  
  101.   vif_WriteProt = $00000040;
  102.   vif_FileInUse = $00000080;
  103.   vif_OutOfSpace = $00000100;
  104.   vif_AccessViolation = $00000200;
  105.   vif_SharingViolation = $00000400;
  106.   vif_CannotCreate = $00000800;
  107.   vif_CannotDelete = $00001000;
  108.   vif_CannotRename = $00002000;
  109.   vif_CannotDeleteCur = $00004000;
  110.   vif_OutOfMemory = $00008000;
  111.  
  112.   vif_CannotReadSrc = $00010000;
  113.   vif_CannotReadDst = $00020000;
  114.  
  115.   vif_BuffTooSmall = $00040000;
  116.  
  117. type
  118.   Pvs_FixedFileInfo = ^Tvs_FixedFileInfo;
  119.   Tvs_FixedFileInfo = record
  120.     dwSignature: Longint;        { e.g. $feef04bd }
  121.     dwStrucVersion: Longint;        { e.g. $00000042 = "0.42" }
  122.     dwFileVersionMS: Longint;        { e.g. $00030075 = "3.75" }
  123.     dwFileVersionLS: Longint;        { e.g. $00000031 = "0.31" }
  124.     dwProductVersionMS: Longint;    { e.g. $00030010 = "3.10" }
  125.     dwProductVersionLS: Longint;    { e.g. $00000031 = "0.31" }
  126.     dwFileFlagsMask: Longint;        { = $3F for version "0.42" }
  127.     dwFileFlags: Longint;        { e.g. vff_Debug | vff_Prerelease }
  128.     dwFileOS: Longint;            { e.g. vos_DOS_Windows16 }
  129.     dwFileType: Longint;        { e.g. vft_DRIVER }
  130.     dwFileSubtype: Longint;        { e.g. vft2_DRV_Keyboard }
  131.     dwFileDateMS: Longint;        { e.g. 0 }
  132.     dwFileDateLS: Longint;        { e.g. 0 }
  133.   end;
  134.  
  135.  
  136. function VerFindFile(Flags: Word; FileName, WinDir, AppDir,
  137.   CurDir: PChar; var CurDirLen: Word; DestDir: PChar;
  138.   var DestDirLen: Word): Word;
  139.  
  140. function VerInstallFile(Flags: Word; SrcFileName, DestFileName,
  141.   SrcDir, DestDir, CurDir, TmpFile: PChar; var TmpFileLen: Word): Longint;
  142.  
  143. { Returns size of version info in bytes }
  144.  
  145. function GetFileVersionInfoSize(
  146.   FileName: PChar;            { Filename of version stamped file }
  147.   var Handle: Longint): Longint;    { Information for use by GetFileVersionInfo }
  148.  
  149. { Read version info into buffer }
  150.  
  151. function GetFileVersionInfo(
  152.   FileName: PChar;            { Filename of version stamped file }
  153.   Handle: Longint;            { Information from GetFileVersionSize }
  154.   Len: Longint;                { Length of buffer for info }
  155.   Data: PChar): Bool;            { Buffer to place the data structure }
  156.  
  157. { Returns size of resource in bytes }
  158.  
  159. function GetFileResourceSize(
  160.   FileName: PChar;            { Filename of version stamped file }
  161.   ResType: PChar;            { Type:  normally vs_File_Info }
  162.   ResID: PChar;                { ID:  normally vs_Version_Info }
  163.   var FileOffset: Longint): Longint;    { Returns file offset of resource }
  164.  
  165. { Reads file resource into buffer }
  166.  
  167. function GetFileResource(
  168.   FileName: PChar;            { Filename of version stamped file }
  169.   ResType: PChar;            { Type:  normally vs_File_Info }
  170.   ResID: PChar;                { ID:  normally vs_Version_Info }
  171.   FileOffset: Longint;            { File offset or NULL }
  172.   ResLen: Longint;            { Length of resource to read or NULL }
  173.   Data: PChar): Bool;            { Pointer to data buffer }
  174.  
  175. function VerLanguageName(Lang: Word; Lang: PChar; Size: Word): Word;
  176.  
  177. {  In VER.H but not exported by any DLL or EXE
  178. function GetWindowsDir(AppDir: PChar; Buffer: PChar; Size: Integer): Word;
  179. function GetSystemDir(AppDir: PChar; Buffer: PChar; Size: Integer): Word;
  180. }
  181.  
  182. function VerQueryValue(Block: Pointer; SubBlock: PChar;    var Buffer: Pointer;
  183.   var Len: Word): Bool;
  184.  
  185. implementation
  186.  
  187. function VerFindFile;                      external 'VER'      index 8;
  188. function VerInstallFile;                   external 'VER'      index 9;
  189. function GetFileVersionInfoSize;           external 'VER'      index 6;
  190. function GetFileVersionInfo;               external 'VER'      index 7;
  191. function GetFileResourceSize;              external 'VER'      index 2;
  192. function GetFileResource;                  external 'VER'      index 3;
  193. function VerLanguageName;                  external 'VER'      index 10;
  194. function VerQueryValue;                    external 'VER'      index 11;
  195.  
  196. end.
  197.